package com.example.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 响应结果类
 * @author wsl
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultVo {
    private Long code;//响应状态码

    private String msg;//响应提示

    private Object data;//响应数据

//    public static ResultVo response(ResultVoEnum resultVoEnum){
//        code = resultVoEnum.getCode();
//    }

    //返回请求成功后的数据
    public static ResultVo response(Object data){
        return new ResultVo(200L,null,data);
    }

    //仅返回请求结果信息
    public static ResultVo ok(String message){
        return new ResultVo(200L,message,null);
    }

    public static ResultVo ok(){
        return new ResultVo(200L,"请求成功",null);
    }

    public static ResultVo ok(String message,Object data){
        return new ResultVo(200L,message,data);
    }

    /**
     * 成功返回结果
     * @param message
     * @return
     */
    public static ResultVo success(String message){
        return new ResultVo(200L,message,null);
    }

    /**
     * 成功返回结果
     * @param message
     * @return
     */
    public static ResultVo success(String message, Object obj){
        return new ResultVo(200L,message,obj);
    }

    /**
     * 失败返回结果
     * @param message
     * @return
     */
    public static ResultVo error(String message){
        return new ResultVo(500L,message,null);
    }

    /**
     * 失败返回结果
     * @param message
     * @return
     */
    public static ResultVo error(Long code,String message){
        return new ResultVo(code,message,null);
    }

    /**
     * 失败返回结果
     * @param message
     * @return
     */
    public static ResultVo error(String message,Object obj){
        return new ResultVo(500L,message,obj);
    }

    public static ResultVo error(){
        return new ResultVo(500L,null,null);
    }
}
